#include <iostream>
#include <cmath>
#include <iomanip>
#include <cstring>

using namespace std;

int main()
{
    string a, b;
    cin >> a >> b;
    int cnta = 1, cntb = 1;
    for (int i = 0; i < a.size(); i++)
    {
        cnta *= a[i] - 'A' + 1;
        // cout << cnta << endl;
    }
    for (int i = 0; i < b.size(); i++)
    {
        cntb *= b[i] - 'A' + 1;
    }
    if (cnta % 47 == cntb % 47)
    {
        cout << "GO";
    }
    else
    {
        cout << "STAY";
    }

    return 0;
}

/*

*/